#!/usr/bin/env python2
#! -*- coding: utf-8 -*-

from multiprocessing import Process, Queue
from gi.repository import Clutter, GdkPixbuf, Cogl, Mx
from Pipe import Pipe
import model
import logging

from MessageListener import MessageListener

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                    datefmt='%m-%d %H:%M')

def button_clicked(actor, event):
    logging.info(str(actor)+" "+str(event.type))

Clutter.init(None)

style = Mx.Style.get_default ()
style.load_from_file("/etc/debrew/style.css")

script = Clutter.Script()
script.load_from_file("/etc/debrew/ui.json")
stage = script.get_object("stage")

l = script.get_object("brew-list")
profiles = model.get_profiles()
for i, profile in enumerate(profiles): 
    logging.debug(profile.title)
    button =  Mx.Button.new_with_label(profile.title)
    button.set_x(25)
    button.set_y(50*i)
    button.connect("event", button_clicked)
    l.add_actor(button)




stage.show()



stage.set_rotation_angle(Clutter.RotateAxis.Z_AXIS, 90.0)
stage.set_rotation_angle(Clutter.RotateAxis.Z_AXIS, 0.0)

listener = MessageListener(script)

Clutter.main()
               

